#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define ONE 0x1
#define TWO 0x2
#define THREE 0x4
#define FOUR 0x8
#define FIVE 0x10
void Print(int flag){
  if(flag & ONE)printf("hello 1\n");
  if(flag & TWO)printf("hello 2\n");
  if(flag & THREE)printf("hello 3\n");
  if(flag & FOUR)printf("hello 4\n");
  if(flag & FIVE)printf("hello 5\n");
}
int main(){
  //umask(0000);
  //Print(ONE);
  //Print(TWO);
  //Print(THREE);
  //Print(FOUR);
  //Print(FIVE);

 
  //close(1);


  // int fd = open("bite",O_WRONLY | O_CREAT | O_TRUNC,0666);
  // char arr[]="i like linux\n";
  // write(fd,arr,strlen(arr));

  // int fd1 = open("bite",O_RDONLY);
  // char buffer[1024];
  // int n =read(fd1,buffer,sizeof(buffer)-1);//使用系统调用注意\0问题
  //   if(n>0){ //如果读取失败返回-1
  //     buffer[n]='\0';
  //     write(1,buffer,n);
  //   }
  // close(fd);
  // close(fd1);


  FILE* fp = fopen("bite","w+");
  char* arr="linux so easy\n";
  fwrite(arr,1,strlen(arr),fp);
  fclose(fp);


  FILE* fp1 = fopen("bite","r");
  char buff[100]="\0";
  fgets(buff,15,fp1);
  printf("%s",buff);
  fclose(fp1);
  
  return 0;
}
